package dry.example.parse;

import com.github.javaparser.StaticJavaParser;
import com.github.javaparser.ast.CompilationUnit;
import com.github.javaparser.ast.body.MethodDeclaration;
import com.github.javaparser.ast.visitor.ModifierVisitor;

import java.io.FileInputStream;

/**
 * @author zc
 */
public class Rename {

    private static final String FILE_PATH = "D:\\zhouchun\\code_self\\spring_cloud_simple\\src\\main\\java\\dry\\example\\parse\\Demo.java";

    public static void main(String[] args) throws Exception {
        CompilationUnit cu = StaticJavaParser.parse(new FileInputStream(FILE_PATH));
        CustomModifierVisitor customModifierVisitor = new CustomModifierVisitor();
        customModifierVisitor.visit(cu, new Parameter());
        System.out.println(cu.toString());
    }

    private static class CustomModifierVisitor extends ModifierVisitor<Parameter> {

        @Override
        public MethodDeclaration visit(MethodDeclaration md, Parameter parameter) {
            super.visit(md, parameter);
            Tool.rename(md, parameter);
            return md;
        }

    }

}
